<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>病案集中归档统计</title>
</head>
<body>
<div class="easyui-panel" data-options="fit:true,border:0">
	<div id="arcStatisticsBar" class="paddingTBL">
	    <div class="paddingB">
		    <select id="arcStatistics_rqlx" class="easyui-combobox" data-options="width:85,height:24">
	        	<option value="1" selected="selected">出院日期</option>
	        	<option value="2">归档日期</option>
	        </select>&nbsp;
			<input type="text" class="easyui-datebox" id="arcStatistics_date1" data-options="width:115,height:24"/>
			<label>&nbsp;至&nbsp;</label>
			<input type="text" class="easyui-datebox" id="arcStatistics_date2" data-options="width:115,height:24"/>
	    	<label class="paddingL">出院科室&nbsp;</label>
			<input type="text" class="" id="arcStatistics_fcydept" data-options="width:120,height:24"/>
	    </div>
	    <span style="width:370px;border:0px solid red"> 
			<label>归档期限设置</label>&nbsp;&nbsp;
			<label>及时归档≤</label>
			<input type="text" class="easyui-numberbox" id="arcStatistics_jsDay" data-options="width:30,height:24"/>
			<label>天</label>&nbsp;&nbsp;
			<label>逾期归档&gt;</label>
			<input type="text" class="easyui-numberbox" id="arcStatistics_yqDay" data-options="width:30,height:24"/>
			<label>天</label>&nbsp;&nbsp;
		</span>
		 
		<span style="width:205px;border:0px solid red"> 
			<label>按时归档介于</label><label id="arcStatistics_jsDay_label"></label><label>至</label><label id="arcStatistics_yqDay_label"></label><label>之间</label>
		</span> 
		<a href="#" class="easyui-linkbutton" onclick="arcStatistics()">查 询</a>
	</div>
 
	<table id="arcStatisticsGrid"></table>
	
	<!-- 逾期归档dialog -->
	<div id="yqgdDialog" class="easyui-dialog"  data-options="closed:true" style="width:600px;height:500px;" >
		<table id="yqgdGrid"></table>
	</div>
	
	<!-- 未归档dialog -->
	<div id="wgdDialog" class="easyui-dialog"  data-options="closed:true" style="width:600px;height:500px;" >
		<table id="wgdGrid"></table>
	</div>
</div>
<script type="text/javascript">
//获取出院科室
$("#arcStatistics_fcydept").combobox({
	url:ctx + "/MedicalShootManage/getDept",
	valueField:"ftykh",
	textField:"fksname",
	width:120, 
	height:24,
	onLoadSuccess : function() {
		$('#arcStatistics_fcydept').combobox('select', 'TZYQY');
		$("#arcStatistics_jsDay").numberbox('setValue',3);
		$("#arcStatistics_yqDay").numberbox('setValue',6);
	}
});
$(function(){
	$("#arcStatistics_jsDay").numberbox({
		onChange:function(){
			var jsDay=$("#arcStatistics_jsDay").numberbox("getValue");
			var yqDay=$("#arcStatistics_yqDay").numberbox("getValue");
			if(jsDay<yqDay||jsDay=="" || yqDay==""||jsDay=="0" || yqDay=="0"){
				$("#arcStatistics_jsDay_label").html(jsDay);
			}else{
				$.messager.alert('提示','及时归档天不能大于逾期归档天！','info');
			}
		}
	});
	
	$("#arcStatistics_yqDay").numberbox({
		onChange:function(){
			var jsDay=$("#arcStatistics_jsDay").numberbox("getValue");
			var yqDay=$("#arcStatistics_yqDay").numberbox("getValue");
			if(jsDay<yqDay||yqDay=="" || jsDay==""||jsDay=="0" || yqDay=="0"){
				$("#arcStatistics_yqDay_label").html(yqDay);
			}else{
				$.messager.alert('提示','逾期归档天不能小于及时归档天！','info');
			}
		}
	});
});
//获取统计数据	
function arcStatistics(){
	var rqlx = $("#arcStatistics_rqlx").combobox("getValue");
	var date1 = $("#arcStatistics_date1").datebox("getValue");
	var date2 = $("#arcStatistics_date2").datebox("getValue");
	var fcydept = $("#arcStatistics_fcydept").combobox("getValue");
	var jsday = $("#arcStatistics_jsDay").numberbox("getValue");
	var yqday = $("#arcStatistics_yqDay").numberbox("getValue");
	$("#arcStatisticsGrid").datagrid({
		url:ctx + "/Archiving/queryStatistics",
		queryParams:{
			"rqlx" : rqlx,
			"date1" : date1,
			"date2" : date2,
			"fcydept" : fcydept,
			"jsday" : jsday,
			"yqday" : yqday
			
		}
	});
}


//加载数据表格
$("#arcStatisticsGrid").datagrid({
	url:'',
	toolbar:"#arcStatisticsBar",
	rownumbers:true,
	fitColumns:false,
	border : false,
	striped : true,
	fit : true,
	singleSelect: true,
	pagination : true,
	pageSize : 20,
	pageList : [ 20, 30,50 ],
	columns:[[
		{field:'fcydept',title:'出院科室',width:100,align:'center'},  
		{field:'total',title:'出院病人总数',width:140,align:'center'},  
		{field:'jsgd',title:'及时归档',width:100,align:'center' },  
		{field:'jsgdl',title:'及时归档率',width:100,align:'center' },  
		{field:'asgd',title:'按时归档',width:100,align:'center'},  
		{field:'asgdl',title:'按时归档率',width:100,align:'center'},  
		{field:'yqgd',title:'逾期归档',width:100,align:'center',
			formatter:function(value,row,index){
				if(value == 0){
					return value;
				}else{
					//操作标识。为true则表示查询那个记录
					var wgd = false; //未归档
					var yqgd = true; //逾期归档
					return "<a href='#' onclick='getYqgdData("+index+","+wgd+","+yqgd+")'>"+value+"</a>";
				}
			}	
		},  
		{field:'yqgdl',title:'逾期归档率',width:100,align:'center' },  
		{field:'wgd',title:'未归档',width:80,align:'center' ,
			formatter:function(value,row,index){
				if(value == 0){
					return value;
				}else{
					var wgd = true;
					var yqgd = false;
					return "<a href='#' onclick='getYqgdData("+index+","+wgd+","+yqgd+")'>"+value+"</a>";
				}
			}	
		},  
		{field:'fcytykh',title:'科室编号',width:100,align:'center' ,hidden:true},  
		{field:'wgdl',title:'未归档率',width:100,align:'center' }
	   ]]
});

//获取逾期归档和未归档数据
function getYqgdData(index,wgd,yqgd){
	var itmes = $("#arcStatisticsGrid").datagrid("getRows")[index];
	var jsday = $("#arcStatistics_jsDay").numberbox("getValue");
	var yqday = $("#arcStatistics_yqDay").numberbox("getValue");
	$("#yqgdDialog").dialog({
		maximizable:true,
        closed: false,
        modal: true,
		title: "病案逾期归档情况统计",
		buttons:[{
			text:"关闭",
			handler:function(){
				$('#yqgdDialog').dialog("close");
			}
		}]
	});
	$("#yqgdGrid").datagrid({
		url : ctx + "/Archiving/getYqgdData",
		toolbar:"",
		queryParams:{
			"fcytykh" : itmes.fcytykh,
			"jsday" : jsday,
			"yqday" : yqday,
			"wgd" : wgd,
			"yqgd" : yqgd
			
		},
		rownumbers:true,
		fitColumns:true,
		border : false,
		striped : true,
		fit : true,
		singleSelect: true,
		pagination : true,
		pageSize : 20,
		pageList : [ 20, 30,50 ],
		columns:[[
			{field:'fcydept',title:'科室',width:80,align:'center'},  
			{field:'fprn',title:'病案号',width:120,align:'center'},  
			{field:'fname',title:'姓名',width:80,align:'center'},  
			{field:'fcydate',title:'出院日期',width:100,align:'center',
				formatter:function(value){
					return new Date(value).format("yyyy-MM-dd");
				}	
			},  
			{field:'fdate',title:'归档日期',width:100,align:'center',
				formatter:function(value){
					if(value != null && value != ""){
						return new Date(value).format("yyyy-MM-dd");
					}else{
						return "";
					}
				}	
			},  
			{field:'days',title:'逾期天数',width:80,align:'center'}  
			
		   ]]
	});
}

</script>
</body>
</html>